let db = require("../db/db")

let handle = async function (action, data, log_info, req, res) {
	switch (action) {
		case "get":
			let group = data.group || req.query.group;
			let sql = "select * from sys_options where `group`=?";
			let result = await db.query(sql, [group]);
			let rows = result.rows;
			if (rows.length == 0) { return (Error('不存在这个选项组,group:' + group)); }
			let options = [];
			for (let row of rows) {
				options.push(row.value);
			}
			return (options);
			break;
		default:
			return (Error('未知的action:' + action));
	}
}

module.exports = { handle };